package com.smart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.model.customdo.ProjectADO;
import com.smart.model.domain.HotWorkDO;
import com.smart.model.request.HotWorkRequest;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author zhanghong
 */
@Repository
public interface HotWorkMapper extends BaseMapper<HotWorkDO> {
    HotWorkDO selectDOById(Long id);

    List<HotWorkDO> selectDOList(HotWorkDO hotWork);

    int insertDO(HotWorkDO hotWork);

    int batchInsertDO(List<HotWorkDO> hotWorkDOList);

    int updateDO(HotWorkDO hotWork);

    int deleteDOById(Long id);

    int deleteDOByIds(String[] ids);

    @Select({"<script>", "   select count(1) from hot_work", "   <where>", "       deleted=0", "       <if test=\"1==0\">and id=#{param.id}</if>", "   </where>", "</script>"})
    long pageCount(@Param("param") HotWorkRequest param);

    @Select({"<script>", "   select * from hot_work", "   <where>", "       deleted=0", "       <if test=\"1==0\">and id=#{param.id}</if>", "   </where>", "   order by create_time desc limit #{limit} offset #{offset}", "</script>"})
    List<HotWorkDO> pageQuery(@Param("param") HotWorkRequest param, @Param("limit") int limit, @Param("offset") long offset);

    Integer selectMaxHotWorkCode();

    HotWorkDO selectDODetailById(long id);

    List<ProjectADO> selectDOListByReq(HotWorkRequest request);

    List<HotWorkDO> pageDetailedList(HotWorkRequest request);

    List<ProjectADO> listQueryManage(HotWorkRequest request);

    Integer selectEightWeeklyData(@Param("projectId") Long projectId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);


    Integer selectEightWeeklyDataByProjectIds(@Param("list") List<Long> projectIds, @Param("startDate") Date startDate, @Param("endDate") Date endDate);

    Integer selectCountByProjectId(@Param("projectId") Long projectId);

    Map<String, Date> selectTimeScop(HotWorkRequest request);

    Integer selectcounts(@Param("projectId") Long projectId, @Param("startDate") java.sql.Date startDate, @Param("endDate") java.sql.Date endDate);

    List<ProjectADO> selectDOListByIds(HotWorkRequest request);

    List<ProjectADO> selectDOListByNowRuning(HotWorkRequest request);

    Integer selectCountByParams(@Param("projectId") Long id, @Param("startDate") Date startTime, @Param("endDate") Date endTime);

    List<Long> selectProjectCountByParams(@Param("startDate") Date startTime, @Param("endDate") Date endTime);

    List<HotWorkDO> selectDeletedVideo();

}
